<!DOCTYPE html5>
<html>
  <head lang="cn-zh">
    <title>Open the Door</title>
    <meta charset="utf-8">
    <link rel="shortcut icon" href="./favicon.ico">
    <link rel="stylesheet" href="./css/style_button.css">
  </head>
  
  <body>
      <div class="open_door_from_js">
        <button onclick="open_door()">开门</button>
        <script>
          function open_door() {
            if (!confirm("确定要打开吗(︶.̮︶✽)")) {
              return;
            }
            fetch('./open_door', {
              method: "POST",
              headers: {	
                'content-type': 'application/json'
              },
              body: JSON.stringify({signal: 'open_door'})
            })
            .then(res => res.json()
            .then(data => alert(data.message)))
          }
        </script>
      </div>

      <div class="open_door_from_html">
        <form action="./open_door" method="post">
          <input type="hidden" name="signal" value="open_door">
          <input type="submit" value="开门！！！">
        </form>
      </div>
      
  </body>
</html>
